#include "Core/Interface.h"

static SystemInterface* gSystemHandler = nullptr;

extern SystemInterface *getAiotAdapterNet(SystemInterface *portfile);
void setSystemInterface(SystemInterface* handler) {
    gSystemHandler = getAiotAdapterNet(handler);
}

SystemInterface* getSystemInterface() {

    if (gSystemHandler == nullptr || gSystemHandler->destroyNet == nullptr ||
        gSystemHandler->memMalloc == nullptr || gSystemHandler->memFree   == nullptr ||
        gSystemHandler->sleep     == nullptr || gSystemHandler->getRand   == nullptr ||
        gSystemHandler->getTimestamp == nullptr || gSystemHandler->createMutex   == nullptr ||
        gSystemHandler->enterMutex == nullptr || gSystemHandler->leaveMutex == nullptr ||
        gSystemHandler->destroyMutex == nullptr || gSystemHandler->createNet == nullptr ||
        gSystemHandler->setNetOption == nullptr || gSystemHandler->netEstablish == nullptr ||
        gSystemHandler->netRecv == nullptr || gSystemHandler->netSend == nullptr ||
        gSystemHandler->destroyNet == nullptr)  {

        return nullptr;
    }

    return gSystemHandler;
}